package com.hdu.controller.collegeManagement;


import com.hdu.pojo.PageBean;
import com.hdu.pojo.Result;
import com.hdu.service.ISchoolService;
import com.hdu.vo.EnrollTable;
import com.hdu.vo.SchoolList;
import com.hdu.vo.SchoolSpecial;
import com.hdu.vo.ScoreTable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学校实体类 前端控制器
 * </p>
 *
 * @author xiaobai
 * @since 2023-10-28
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "学校管理接口")
@RequestMapping("/school")
public class SchoolController {

    private final ISchoolService schoolService;

    @ApiOperation("分页获取学校列表")
    @GetMapping("/page")
    public Result<PageBean<SchoolList>> page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       String level, String special, String type, String region, String name) {
        log.info("分页获取专业列表, 参数: {},{},{},{},{},{},{}", page, limit, level, region, type, special, name);
        PageBean<SchoolList> pageBean = schoolService.schoolPage(page, limit, level, region, type, special, name);
        return Result.success(pageBean);
    }

    @ApiOperation("分页获取学校排名列表")
    @GetMapping("/rank")
    public Result<PageBean<SchoolList>> page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       Integer type) {
        log.info("分页获取专业列表, 参数: {},{},{}", page, limit, type);
        PageBean<SchoolList> pageBean = schoolService.schoolRank(page, limit, type);
        return Result.success(pageBean);
    }

    @ApiOperation("获取学校概述")
    @GetMapping("/overview/{id}")
    public Result<?> overview(@PathVariable String id) {
        log.info("获取专业概述, id: {}", id);
        return Result.success(schoolService.overview(id));
    }

    @ApiOperation("分页获取学校开设专业")
    @GetMapping("/special")
    public Result<PageBean<SchoolSpecial>> special(@RequestParam(defaultValue = "1") Integer page,
                          @RequestParam(defaultValue = "10") Integer limit,
                          String id, String name, String type) {
        log.info("分页获取学校开设专业, 参数: {},{},{},{},{}", page, limit, id, name, type);
        PageBean<SchoolSpecial> pageBean = schoolService.special(page, limit, id, name, type);
        return Result.success(pageBean);
    }

    @ApiOperation("获取学校开设专业导航")
    @GetMapping("/special/{id}")
    public Result<?> special(@PathVariable String id) {
        log.info("获取学校开设专业导航, 参数: {}", id);
        return Result.success(schoolService.specialType(id));
    }

    @ApiOperation("分页获取学校招生计划")
    @GetMapping("/enroll")
    public Result<PageBean<EnrollTable>> enroll(@RequestParam(defaultValue = "1") Integer page,
                         @RequestParam(defaultValue = "10") Integer limit,
                         Integer id, Integer region, Integer type, Integer batch) {
        log.info("分页获取学校招生计划, 参数: {},{},{},{},{}", page, limit, id, batch, type);
        PageBean<EnrollTable> pageBean = schoolService.enroll(page, limit, id, region, batch, type);
        return Result.success(pageBean);
    }

    @ApiOperation("获取学校招生计划导航")
    @GetMapping("/enroll/{id}")
    public Result<?> enroll(@PathVariable String id) {
        log.info("获取学校招生计划导航, 参数: {}", id);
        return Result.success(schoolService.enrollSelect(id));
    }

    @ApiOperation("获取学校各省分数线")
    @GetMapping("/hire")
    public Result<?> hire(Integer id, Integer region, String year, Integer type) {
        log.info("获取学校各省分数线, 参数: {},{},{},{}", id, region, year, type);
        return Result.success(schoolService.hire(id, region, year, type));
    }

    @ApiOperation("获取学校各省分数线导航")
    @GetMapping("/hire/{id}")
    public Result<?> hire(@PathVariable String id) {
        log.info("获取学校各省分数线导航, 参数: {}", id);
        return Result.success(schoolService.hireSelect(id));
    }

    @ApiOperation("获取学校专业分数线")
    @GetMapping("/score")
    public Result<PageBean<ScoreTable>> score(@RequestParam(defaultValue = "1") Integer page,
                        @RequestParam(defaultValue = "10") Integer limit,
                        Integer id, Integer region,String year, Integer type, Integer batch) {
        log.info("分页获取学校招生计划, 参数: {},{},{},{},{},{}", page, limit, id, batch, type,year);
        PageBean<ScoreTable> pageBean = schoolService.score(page, limit, id, region, batch, type,year);
        return Result.success(pageBean);
    }

    @ApiOperation("获取学校专业分数线导航")
    @GetMapping("/score/{id}")
    public Result<?> score(@PathVariable String id) {
        log.info("获取学校专业分数线导航, 参数: {}", id);
        return Result.success(schoolService.scoreSelect(id));
    }


    @ApiOperation("按类获取热门学校")
    @GetMapping("/hot/{type}")
    public Result<?> special(@PathVariable Integer type) {
        log.info("按类获取热门学校, 参数: {}", type);
        return Result.success(schoolService.hotSchool(type));
    }

}
